home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / textfield.lha / Textfield / MUITest / muitest.c < prev    next >
C/C++ Source or Header  |  1995-06-21  |  3KB  |  119 lines

  1. /*
  2.  * muitest.c was generated with MUIBuilder, except for the part
  3.  * that makes the Textfield gadget, which I just modified from
  4.  * from a list object.
  5.  *
  6.  * V1.1 modifications - a scroll bar has been added that interacts
  7.  * with the textfield object.
  8.  *
  9.  * When using the Textfield gadget in MUI, I suggest you use the
  10.  * frames and labels that it provides instead of the features
  11.  * builtin to the Textfield gadget.  This way, MUI has a better
  12.  * idea how to correctly layout the graphics elements.
  13.  */
  14.  
  15. #include <libraries/mui.h>
  16. #include <proto/muimaster.h>
  17. #include <clib/exec_protos.h>
  18. #include <exec/memory.h>
  19. #include <intuition/icclass.h>
  20. #include <gadgets/textfield.h>
  21.  
  22. #include <proto/textfield.h>
  23. #include <proto/iffparse.h>
  24.  
  25. #ifndef MAKE_ID
  26. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  27. #endif
  28.  
  29. #ifdef _DCC
  30. #define __inline
  31. #endif
  32.  
  33. #define MUIA_Boopsi_Smart 0x8042b8d7 /* V9 i.. BOOL */
  34.  
  35. static struct ClipboardHandle *clip_handle, *undo_handle;
  36.  
  37. /*    ExTended KeyButton ( or Eric Totel KeyButton :-) )    */
  38. /*    to use with localization features             */
  39.  
  40. static APTR __inline ETKeyButton(char *text)
  41. {
  42.         return (KeyButton(&text[3], text[1]));
  43. }
  44.  
  45. #include "muitest.h"
  46.  
  47. struct ObjApp * CreateApp( void )
  48. {
  49.     struct ObjApp * Object;
  50.  
  51.     if (!(Object = AllocVec( sizeof( struct ObjApp ), MEMF_PUBLIC|MEMF_CLEAR )))
  52.         return( NULL );
  53.  
  54.     clip_handle = OpenClipboard(0);
  55.     undo_handle = OpenClipboard(42);
  56.  
  57.     Object->App = ApplicationObject,
  58.         MUIA_Application_Author, "Mark Thomas",
  59.         MUIA_Application_Base, "MUITEST",
  60.         MUIA_Application_Title, "MUITest",
  61.         MUIA_Application_Version, "$VER: MUI 1.1 (4.12.94)",
  62.         MUIA_Application_Copyright, "FREE",
  63.         MUIA_Application_Description, "Test textfield.gadget with MUI",
  64.         SubWindow, Object->window = WindowObject,
  65.             MUIA_Window_Title, "Test MUI - BOOPSI",
  66.             MUIA_Window_ID, MAKE_ID( '0','W','I','N' ),
  67.             WindowContents, GroupObject,
  68.                 MUIA_Group_Horiz, TRUE,
  69.                 Child, Object->text = BoopsiObject,  /* MUI and Boopsi tags mixed */
  70.                     InputListFrame,
  71.                     MUIA_Boopsi_Class,        TextFieldClass,
  72.                     MUIA_Boopsi_Smart,        TRUE,
  73.                     MUIA_Boopsi_MinWidth,    40, /* boopsi objects don't know */
  74.                     MUIA_Boopsi_MinHeight,    40, /* their sizes, so we help   */
  75.                     ICA_TARGET,                ICTARGET_IDCMP, /* needed for notification */
  76.                     TEXTFIELD_Text,            (ULONG)"Hello?",
  77.                     TEXTFIELD_ClipStream,    clip_handle,
  78.                     TEXTFIELD_UndoStream,    undo_handle,
  79.                 End,
  80.                 Child, Object->sbar = ScrollbarObject, End,
  81.             End,
  82.         End,
  83.     End;
  84.  
  85.     if (!(Object->App))
  86.     {
  87.         if (undo_handle)
  88.         {
  89.             CloseClipboard(undo_handle);
  90.             undo_handle = NULL;
  91.         }
  92.         if (clip_handle)
  93.         {
  94.             CloseClipboard(clip_handle);
  95.             clip_handle = NULL;
  96.         }
  97.         FreeVec(Object);
  98.         Object = NULL;
  99.     }
  100.  
  101.     return( Object );
  102. }
  103.  
  104. void DisposeApp( struct ObjApp * Object )
  105. {
  106.     MUI_DisposeObject(Object->App);
  107.     if (undo_handle)
  108.     {
  109.         CloseClipboard(undo_handle);
  110.         undo_handle = NULL;
  111.     }
  112.     if (clip_handle)
  113.     {
  114.         CloseClipboard(clip_handle);
  115.         clip_handle = NULL;
  116.     }
  117.     FreeVec( Object );
  118. }
  119.